

<style type="text/css">
  .credit_card_2017 td {
    padding: 3px;
  }

  .credit_card_2017 table.noborder td {
    border: none;
    padding: 0 3px;
  }

  .credit_card_2017 input[type=button] {
    cursor: pointer;
  }

  .credit_card_2017 .red {
    color: #fb1414;
  }

  .credit_card_2017 .red1 {
    color: #ce2929;
    font-weight: bold;
  }

  .clear0 {
    clear: both;
    width: 100%;
    font-size: 0;
    height: 0px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    line-height: 0px;
  }

  .clear {
    clear: both;
    width: 100%;
    font-size: 0;
    height: 15px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    line-height: 0px;
  }

  .clear20 {
    clear: both;
    width: 100%;
    font-size: 0;
    height: 20px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    line-height: 0px;
  }

  .clear5 {
    clear: both;
    width: 100%;
    font-size: 0;
    height: 5px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    line-height: 0px;
  }

  .clear10 {
    clear: both;
    width: 100%;
    font-size: 0;
    height: 10px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    line-height: 0px;
  }

  .credit_card_2017 .accept_box {
    width: 100%;
    height: 170px;
    margin-bottom: 20px
  }

  .credit_card_2017 .billing_address {
    position: relative;
    padding-top: 10px;
  }

  .credit_card_2017 .billing_address .tit {
    font-size: 14px;
    font-weight: normal;
    margin-bottom: 15px;
    position: relative;
    line-height: 20px;
    height: 20px;
  }

  .credit_card_2017 .billing_address .tit .badd_titr {
    position: absolute;
    right: 0;
    top: 0;
  }

  .credit_card_2017 .billing_address .tit .badd_titr select {
    height: 20px;
  }

  .credit_card_2017 .billing_address .baddress_con {
    border: 1px solid #ccc;
    border-radius: 4px;
    position: relative;
    z-index: 10;
    background: #fff;
  }

  .credit_card_2017 .billing_address .baddress_con p {
    height: 42px;
    line-height: 42px;
    padding-left: 15px;
    border-bottom: 1px solid #ccc;
  }

  .credit_card_2017 .billing_address .baddress_con .radio_2 {
    border: 0;
  }

  .credit_card_2017 .billing_address .baddress_con .badd_radio {
    vertical-align: middle;
    margin-right: 4px;
    cursor: pointer;
  }

  .credit_card_2017 .billing_address .address_pop {
    background: #fbfbfb;
    border: 1px solid #ccc;
    border-top: 0;
    border-radius: 0 0 4px 4px;
    z-index: 9;
    padding: 30px 20px 0;
    overflow: hidden;
    margin-top: -4px;
    display: none;
  }

  .credit_card_2017 .billing_address .address_pop .accept_txt {
    float: left;
    width: 100%;
    border: 1px solid #ccc;
    height: 34px;
    line-height: 34px;
    border-radius: 4px;
    text-indent: 10px;
    margin-bottom: 15px;
    background: #fff;
  }

  .credit_card_2017 .billing_address .address_pop .leftright_txt .accept_txt {
    width: 275px;
  }

  .credit_card_2017 .billing_address .address_pop .fr {
    float: right;
  }

  .credit_card_2017 .billing_address .address_btn {
    display: block;
    height: 46px;
    line-height: 46px;
    text-align: center;
    border-radius: 4px;
    background: #4c4c4c;
    text-align: center;
    font-size: 16px;
    color: #fff;
    border: 0;
    width: 330px;
    margin: 0 auto;
  }

  .credit_card_2017 .accept_top {
    padding-bottom: 15px;
    padding-top: 0px;
    overflow: hidden;
    position: relative;
    height: 30px;
  }

  .credit_card_2017 .accept_top a.pic {
    display: inline-block;
    width: 57px;
    height: 26px;
    vertical-align: middle;
    border: 1px solid #ccc;
    margin-left: 10px;
    color: #333;
  }

  .credit_card_2017 .accept_top .tit {
    font-size: 16px;
    margin-bottom: 15px;
    position: relative;
    line-height: 20px;
    height: 20px;
  }

  .credit_card_2017 .accept_top a.pic span {
    display: inline-block;
    height: 100%;
    vertical-align: middle;
  }

  .credit_card_2017 .accept_top a.pic img {
    max-width: 57px;
    max-height: 26px;
    vertical-align: middle;
  }

  .credit_card_2017 .accept_con .cardno_con {
    position: relative;
  }

  .credit_card_2017 .accept_con .cardno_con img {
    height: 30px;
    position: absolute;
    right: 5px;
    top: 3px;
    display: none;
  }

  .credit_card_2017 .accept_con .accept_txt {
    float: left;
    width: calc(33.3333% - 12px) !important;
    box-sizing: border-box;
    border: 1px solid #ccc;
    height: 34px;
    line-height: 34px;
    border-radius: 4px;
    text-indent: 10px;
    margin-bottom: 15px;
  }

  .credit_card_2017 .accept_con .select {
    height: 36px;
    margin-right: 18px !important;
    width: 199px;
  }

  .credit_card_2017 .accept_con .expiration {
    float: right;
    width: 300px;
  }

  .credit_card_2017 .accept_con .expiration .accept_txt {
    width: 143px;
  }

  .credit_card_2017 .accept_con .fr {
    float: right;
  }

  .credit_card_2017 .accept_btn {
    display: block;
    height: 46px;
    line-height: 46px;
    text-align: center;
    border-radius: 4px;
    background: #149EE3;
    text-align: center;
    font-size: 16px;
    color: #fff;
    border: 0;
    width: 100%;
    cursor: pointer;
    font-weight: bold;
  }

  .credit_card_2017 .accept_btn[disabled] {
    background: #ccc
  }

  .accept_top .badd_titr {
    position: absolute;
    right: 0;
    top: 5px;
  }


  .credit_card_2017 .accept_top .order_radio_box {
    padding: 10px 0 0
  }

  .credit_card_2017 .accept_top .order_radio_box .radio_label {
    padding: 0
  }




  .credit_card_2017 .cardno_date .valid-date {
    width: calc(50% - 12px);
  }

  .credit_card_2017 .cardno_date .valid-date .accept_txt {
    width: 100% !important;
  }

  .credit_card_2017 .cardno_date .valid-date.valid-err input {
    border: 1px solid red
  }

  .credit_card_2017 .cardno_date .valid-date.cvv {
    float: right
  }

  .credit_card_2017 .accept_cvv {
    float: right !important
  }

  .credit_card_2017 .accepted_payment_list {
    display: flex;
  }

  .credit_card_2017 .accepted_payment_list .accepted_payment_image {
    display: flex;
    align-item: center;
    border: 1px solid #d9d9d9;
    margin-left: 10px
  }

  .credit_card_2017 .accepted_payment_list .accepted_payment_image_more {
    margin-left: 10px
  }

  .credit_card_2017 .accepted_payment_list img {
    width: 40px;
    height: 20px
  }

  .credit_card_2017 .valid-date {
    position: relative;
    display: inline-block;
  }

  .credit_card_2017 .valid-err .err {
    color: red;
    position: absolute;
    left: 0;
    bottom: -5px;
  }
</style>
<style>
  .custom_second_party_card .accept_box {
    height: auto !important;
  }

  .custom_second_party_card .accept_con .cardno_date {
    text-align: left !important;
    display: flex;
    justify-content: space-between;
  }

  .custom_second_party_card .cardno_con {
    margin-bottom: 16px !important;
  }

  input::-webkit-input-placeholder {
    color: #737373;
    font-size: 13px;
  }

  .credit_card_2017 .accept_con .cardno_con img {
    top: 50% !important;
    margin-top: -15px;
  }

  .custom_second_party_card .accept_con .accept_txt {
    margin-bottom: 0 !important;
    float: initial !important;
    height: 48px !important;
    line-height: 48px !important;
    border: 1px solid #ddd !important;
    width: 100% !important;
  }

  .custom_second_party_card .valid-err .err {
    position: static !important;
  }

  .second_party_card_load {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .second_party_card_load .cell-item {
    height: 48px;
    background: #ddd;
  }

  .valid-err .accept_txt {
    border: 1px solid red !important
  }

  .valid-err .err {
    color: red;
    position: absolute;
    left: 0;
    bottom: -5px;
    text-align: left;
  }

  #three_nested_paypal_warp,
  #three_nested_warp,
  #paypal-checkout-button-custom {
    min-width: 200px;
    width: 100%;
    display: none;
  }

  .paypal-checkout-button-custom {
    display: none;
  }

  .order_payment_method .order_contact_information_btn .return_cart {
    flex-shrink: 0;
  }


  .custom_second_party_card .err {
    margin-top: 4px;
    color: #eb1c26 !important;
  }

  .custom_second_party_card .valid-err .accept_txt {
    border: 2px solid #eb1c26 !important;
    color: #eb1c26 !important;
  }

  .custom_second_party_card .accept_con .cardno_con img {
    top: 10px !important;
    margin-top: 0 !important;
  }

  .custom_second_party_card .cardno_date .valid-date {
    width: calc(50% - 10px) !important;
  }

  .custom_second_party_card .cardno_date .valid-date {
    width: calc(50% - 10px) !important;
  }

  .custom_second_party_card .cardno_con {
    margin-bottom: 20px !important;
  }

  .custom_second_party_card .accept_box svg {
    position: absolute;
    top: 8px;
    right: 12px;
  }

  .custom_second_party_card .valid-date {
    position: relative;
  }

  .custom_second_party_card .cardno_con .default-svg {}

  .custom_second_party_card .cardno_con .err-svg {
    display: none
  }


  @media screen and (max-width: 896px) {
    .custom_second_party_card .cardno_con {
      margin-bottom: 10px !important;
    }

    .custom_second_party_card .accept_con .cardno_date {
      flex-wrap: wrap;
      gap: 10px;
    }

    .custom_second_party_card .cardno_date .valid-date {
      width: 100% !important;
    }
  }
</style>
<div class="credit_card_2017 custom_second_party_card">
  <form action="" method="post" id="form_post" autocomplete="off">

    <div class="accept_box">
      <div class="accept_con">
        <div class="cardno_con">
          <input class="accept_txt nc_text" type="text" id="cardno_cover" autocomplete="off"
            value="" key_name="cardno" placeholder="卡号" maxlength="23" style="width: 618px;" />
          <input type='hidden' name="cardno" value='' />
          <input type="hidden" class="card_type" name="card_type" value='' />
          <img>
          <svg t="1695180570444" class="default-svg" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6837" width="32" height="32"><path d="M28.444444 170.666667m56.888889 0l824.888889 0q56.888889 0 56.888889 56.888889l0 597.333333q0 56.888889-56.888889 56.888889l-824.888889 0q-56.888889 0-56.888889-56.888889l0-597.333333q0-56.888889 56.888889-56.888889Z" fill="#DCDFE6" p-id="6838"></path><path d="M113.777778 655.985778h142.222222v85.333333h-142.222222z" fill="#B2B8C8" p-id="6839"></path><path d="M322.872889 655.985778h142.222222v85.333333h-142.222222z" fill="#B2B8C8" p-id="6840"></path><path d="M531.911111 655.985778h142.222222v85.333333h-142.222222z" fill="#B2B8C8" p-id="6841"></path><path d="M741.006222 655.985778h142.222222v85.333333h-142.222222z" fill="#B2B8C8" p-id="6842"></path><path d="M113.777778 284.444444h341.333333v199.111112h-341.333333z" fill="#FFFFFF" p-id="6843"></path></svg><svg t="1695186478733" class="err-svg" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7059" width="32" height="32"><path d="M28.444444 170.666667m56.888889 0l824.888889 0q56.888889 0 56.888889 56.888889l0 568.888888q0 56.888889-56.888889 56.888889l-824.888889 0q-56.888889 0-56.888889-56.888889l0-568.888888q0-56.888889 56.888889-56.888889Z" fill="#F2A4B3" p-id="7060"></path><path d="M113.777778 341.333333h341.333333v199.111111h-341.333333z" fill="#FFFFFF" p-id="7061"></path><path d="M113.777778 682.666667h142.222222v56.888889h-142.222222z" fill="#DF1B41" p-id="7062"></path><path d="M312.888889 682.666667h142.222222v56.888889h-142.222222z" fill="#DF1B41" p-id="7063"></path><path d="M540.444444 682.666667h142.222223v56.888889h-142.222223z" fill="#DF1B41" p-id="7064"></path><path d="M768 682.666667h113.777778v56.888889h-113.777778z" fill="#DF1B41" p-id="7065"></path><path d="M782.222222 355.555556m-241.777778 0a241.777778 241.777778 0 1 0 483.555556 0 241.777778 241.777778 0 1 0-483.555556 0Z" fill="#DF1B41" p-id="7066"></path><path d="M819.342222 194.503111l-11.207111 246.129778h-41.699555l-11.377778-246.129778z m-61.980444 286.321778h58.766222v55.722667h-58.766222z" fill="#FFFFFF" p-id="7067"></path></svg>
        </div>
        <div class="cardno_date">
          <div class="valid-date date"><input class="accept_txt nc_text" type="text" name="date"
              autocomplete="off" value="" placeholder="有效期限(MM/YY)" oninput="checkDate(event)" />
          </div>
          <div class="valid-date cvv"><input class="accept_txt nc_text accept_cvv" type="text"
              id="cvv_cover" name="cvv" autocomplete="off" value="" placeholder="安全码 (CVV)"
              onkeyup="value=value.replace(/[^\d]/g,'')" maxlength="4" />
            <svg t="1695187108324" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7207" width="32" height="32"><path d="M28.444444 170.666667m56.888889 0l824.888889 0q56.888889 0 56.888889 56.888889l0 597.333333q0 56.888889-56.888889 56.888889l-824.888889 0q-56.888889 0-56.888889-56.888889l0-597.333333q0-56.888889 56.888889-56.888889Z" fill="#E2E2E4" p-id="7208"></path><path d="M28.444444 284.444444h938.666667v113.777778h-938.666667z" fill="#B3B3B8" p-id="7209"></path><path d="M113.777778 568.888889m42.666666 0l682.666667 0q42.666667 0 42.666667 42.666667l0 0q0 42.666667-42.666667 42.666666l-682.666667 0q-42.666667 0-42.666666-42.666666l0 0q0-42.666667 42.666666-42.666667Z" fill="#FFFFFF" p-id="7210"></path><path d="M782.222222 384m-241.777778 0a241.777778 241.777778 0 1 0 483.555556 0 241.777778 241.777778 0 1 0-483.555556 0Z" fill="#6D6E78" p-id="7211"></path><path d="M676.750222 313.116444v183.978667h-37.774222v-141.653333a66.929778 66.929778 0 0 1-19.057778 10.865778 87.523556 87.523556 0 0 1-22.186666 5.973333v-32.199111a167.822222 167.822222 0 0 0 55.068444-26.965334z m40.334222 144.782223a68.266667 68.266667 0 0 0 42.069334 13.482666 39.253333 39.253333 0 0 0 24.177778-6.741333 22.584889 22.584889 0 0 0 8.931555-19.057778 21.731556 21.731556 0 0 0-10.524444-19.626666 55.608889 55.608889 0 0 0-29.809778-6.741334h-16.128v-28.928h14.648889q36.266667 0 36.266666-24.405333 0-23.011556-27.761777-23.011556a61.041778 61.041778 0 0 0-35.214223 11.861334v-31.032889a93.866667 93.866667 0 0 1 43.776-9.642667 67.953778 67.953778 0 0 1 41.472 11.804445 38.428444 38.428444 0 0 1 15.928889 32.711111 42.183111 42.183111 0 0 1-35.669333 44.344889v0.568888a47.587556 47.587556 0 0 1 30.094222 13.767112 39.395556 39.395556 0 0 1 11.377778 28.444444 47.701333 47.701333 0 0 1-18.773333 40.078222 80.042667 80.042667 0 0 1-50.119111 14.449778 93.866667 93.866667 0 0 1-44.743112-9.130667z m124.700445 34.531555v-32.426666a75.377778 75.377778 0 0 0 39.822222 11.377777 36.693333 36.693333 0 0 0 24.917333-7.850666 26.680889 26.680889 0 0 0 9.016889-21.219556q0-28.017778-38.343111-28.017778a294.229333 294.229333 0 0 0-32.654222 2.104889l6.741333-99.356444h95.431111v30.919111h-65.052444l-2.56 37.888q9.642667-0.824889 17.777778-0.824889a58.282667 58.282667 0 0 1 41.671111 14.421333 51.2 51.2 0 0 1 15.274667 39.054223 58.083556 58.083556 0 0 1-18.488889 44.458666 70.627556 70.627556 0 0 1-50.204445 17.265778 107.349333 107.349333 0 0 1-43.349333-7.793778z" fill="#FFFFFF" p-id="7212"></path></svg>
            </div>
        </div>
      </div>
      <div style="text-align: left;margin-top: 10px;font-size: 12px;color: #4c4c4c;display: flex;">
        <svg style="position: static;vertical-align: top;flex-shrink: 0" t="1701679681230"
          class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
          p-id="7137" width="16" height="16">
          <path
            d="M484.010667 979.157333a562.304 562.304 0 0 1-385.152-534.229333V231.936a42.666667 42.666667 0 0 1 30.72-40.96l356.053333-103.893333A42.666667 42.666667 0 0 1 497.621333 85.333333a41.984 41.984 0 0 1 11.946667 1.749334l355.754667 103.893333a42.666667 42.666667 0 0 1 30.677333 40.96v213.077333a562.261333 562.261333 0 0 1-384.981333 534.144 42.666667 42.666667 0 0 1-13.482667 2.176 42.410667 42.410667 0 0 1-13.525333-2.176zM184.192 263.936v181.034667a477.098667 477.098667 0 0 0 313.301333 448.554666 477.056 477.056 0 0 0 313.130667-448.469333V263.978667l-313.045333-91.477334z m239.36 402.730667L282.026667 525.184a42.666667 42.666667 0 0 1 0-60.330667 42.666667 42.666667 0 0 1 60.373333 0l111.274667 111.274667 212.352-212.352a42.666667 42.666667 0 0 1 60.373333 0 42.666667 42.666667 0 0 1 0 60.373333l-242.517333 242.474667a42.666667 42.666667 0 0 1-30.208 12.501333 42.666667 42.666667 0 0 1-30.165334-12.458666z"
            fill="#25BB85" p-id="7138"></path>
        </svg>
        <span style="margin-left: 2px;line-height: 16px;display: inline-block">根据 PCI DSS
          标准保证卡信息的安全。</span>
      </div>
    </div>
    <button type="button" style="margin-top: 10px;display: block !important;" class="accept_btn"
      id="onlypay_submit" disabled><span class="nc_text" key_name="button">Pay</span> </button>
  </form>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
  (function () {
      function  luhnCheckPaycard(payCard) {

      payCard = String(payCard)
      var payCard = payCard.replace(/\s/g, '');
      if (payCard == "") {
          return false;
      }
      if (!/^\d*$/.exec(payCard)) {
          return false;
      }
      
      let sum = 0; 
      let alternate = false; 

      for (let i = payCard.length - 1; i >= 0; i--) {
          let currentNum = parseInt(payCard[i], 10);
          if (alternate) {
          currentNum *= 2;
              if (currentNum > 9) {
                  currentNum -= 9;
              }
          }

          sum += currentNum; 
          alternate = !alternate;
      }

      return sum % 10 === 0;
  
  }
    const cardTypes = {
      visa: {
        name: "visa", //visa
        patterns: [4],
        lengths: [13, 16, 18, 19],
        imgUrl: "/statics/cart/accepted_payment_brand/visa.svg",
        skip_luhn: false
      }
    };
    // 1限制全部，2限制部分，0不限制
    let cardRule = { type: 1, list: [] };

    function isValidInputType(cardNumber) {
      return typeof cardNumber === "string" || cardNumber instanceof String;
    }

    function getValidCardTyps(isAll) {
      if (isAll) {
        return Object.keys(cardTypes);
      }
      if (cardRule.type == 1) {
        return Object.keys(cardTypes);
      }
      if (cardRule.type == 2) {
        return cardRule.list.map((item) => item.name);
      }
      return [];
    }

    function clone(originalObject) {
      if (!originalObject) {
        return null;
      }
      return JSON.parse(JSON.stringify(originalObject));
    }

    function matchesRange(cardNumber, min, max) {
      const maxLengthToCheck = String(min).length;
      const substr = cardNumber.substr(0, maxLengthToCheck);
      const integerRepresentationOfCardNumber = parseInt(substr, 10);

      min = parseInt(String(min).substr(0, substr.length), 10);
      max = parseInt(String(max).substr(0, substr.length), 10);
      return integerRepresentationOfCardNumber >= min && integerRepresentationOfCardNumber <= max;
    }

    function matchesPattern(cardNumber, pattern) {
      pattern = String(pattern);
      return pattern.substring(0, cardNumber.length) === cardNumber.substring(0, pattern.length);
    }

    function matches(cardNumber, pattern) {
      if (Array.isArray(pattern)) {
        return matchesRange(cardNumber, pattern[0], pattern[1]);
      }
      return matchesPattern(cardNumber, pattern);
    }
    function addMatchingCardsToResults(cardNumber, cardConfiguration, results) {
      let i, patternLength;

      for (i = 0; i < cardConfiguration.patterns.length; i++) {
        const pattern = cardConfiguration.patterns[i];

        if (!matches(cardNumber, pattern)) {
          continue;
        }

        const clonedCardConfiguration = clone(cardConfiguration);

        if (Array.isArray(pattern)) {
          patternLength = String(pattern[0]).length;
        } else {
          patternLength = String(pattern).length;
        }


        if (cardNumber.length >= patternLength) {
          clonedCardConfiguration.matchStrength = patternLength;
          clonedCardConfiguration.accurateMatch = Array.isArray(pattern) ? false : true;
        }

        results.push(clonedCardConfiguration);
        break;
      }
    }


    function verification(card, isValid, msg) {
      return {
        card,
        msg,
        isValid
      };
    }


    function oemCreditCard(options) {
      cardRule = options.rule;
    }
    oemCreditCard.creditCardType = function (cardNumber, allType) {
      const results = [];

      if (!isValidInputType(cardNumber) || cardNumber.length === 0) {
        return results;
      }

      getValidCardTyps(allType).forEach((cardType) => {
        const cardConfiguration = cardTypes[cardType];
        addMatchingCardsToResults(cardNumber, cardConfiguration, results);
      });

      if (results.length) {
        const matchStrengthTypes = results.filter((result) => result.matchStrength);
        if (matchStrengthTypes.length) {

          matchStrengthTypes.sort((a, b) => b.matchStrength - a.matchStrength);

          const dankort = matchStrengthTypes.find(item => item.name === "dankort");
          if (dankort) {
            return [dankort]
          }

          const accurate = matchStrengthTypes.find(item => item.accurateMatch);
          if (accurate && accurate.matchStrength >= matchStrengthTypes[0].matchStrength) {
            return [accurate];
          }
          return [matchStrengthTypes[0]];
        }
      }

      return results;
    };

    oemCreditCard.cardNumber = function (value) {
      const testCardValue = String(value).replace(/[^0-9]/g, "");
      const potentialTypes = this.creditCardType(testCardValue, true);
      // 检测空
      if (!value.length) {
        return verification(null, false, lang.checkout.card_number_incomplete);
      }
      if (!cardRule.type) {
        return verification(null, true, "");
      }


      // 检查查询不到匹配的类型
      if (potentialTypes.length === 0) {
        return verification(null, false, lang.checkout.card_not_supported);
      } else if (potentialTypes.length !== 1) {
        return verification(null, false, lang.checkout.card_number_incomplete);
      }

      const cardType = potentialTypes[0];

      // 检查卡号类型不一致
      if (cardRule.type == 2 && !cardRule.list.map(item => item.name).includes(cardType.name)) {
        return verification(null, false, lang.checkout.card_not_supported);
      }

      if (!cardType.lengths.includes(testCardValue.length)) {
        return verification(cardType, false, lang.checkout.card_number_incomplete);
      }

    

      return verification(cardType, true, "");
    };

    window["oemCreditCard"] = oemCreditCard;
  })();




  function getCardConfig(config) {
    const config_json = config.config_param;
    if (config_json && config_json.card_config) {
      return config_json.card_config
    }
    return { type: 1, list: [] }
  }
  function secondCardErrorShow(node, msg, isScrollTop = true) {
    node.parent().addClass('valid-err')
    var dom = '<div class="err">' + msg + '</div>';
    var errorNode = node.parent().find(".err");
    if (errorNode.length) {
      errorNode.html(msg)
    } else {
      node.parent().append(dom);
    }
  }


  function secondCardValids() {

    function encryptionCardno(value) {
      value = value.replace(/\s/g, '');
      if (value) {
        return Number(value).toString(2)
      }
      return ""
    }

    function validCardno(isCollect, isScrollTop = true) {
      var cardnoNode = $("input[name='cardno']");
      var cardno_val = cardnoNode.val();
      var validResult = oemCreditCard.cardNumber(cardno_val);
      if (!validResult.isValid) {
        secondCardErrorShow(cardnoNode, validResult.msg, isScrollTop);
        return false
      }
      return true
    }

    function validCardDate(isCollect, isScrollTop = true) {


      function checkExpire(val) {
        if (!val) {
          return false
        }
        var currentDate = new Date();
        var year = parseInt(currentDate.getFullYear().toString().substr(2, 4));
        var month = currentDate.getMonth() + 1;
        var arr = val.split(' / ');
        month = month > 9 ? month : `0${month}`;
        // 检查日期是否大于当前日期
        if (arr.length == 2 && parseInt(arr[1].toString() + arr[0].toString()) >= parseInt(year.toString() + month.toString())) {
          return true;
        }
        return false;
      }

      var dateNode = $("input[name='date']");
      var reg = /^\d{2}\s\/\s\d{2}/g;
      var data_val = dateNode.val();

      var resultReg = reg.test(data_val);
      var resultCheckExpire = checkExpire(data_val);

      if (!resultReg || !resultCheckExpire) {
        const errorMsg = !resultReg ? lang.checkout.time_input : lang.checkout.card_expire
        secondCardErrorShow(dateNode, errorMsg, isScrollTop);
        return false
      }
      return true
    }

    function validCardCVV(isCollect, isScrollTop = true) {
      var cvvNode = $("input[name='cvv']");
      var cvv_val = cvvNode.val();
      if (checkEmpty(cvv_val) || (cvv_val.length < 3 || cvv_val.length > 4)) {
        secondCardErrorShow(cvvNode, lang.checkout.cvv_input, isScrollTop);
        return false
      }
      return true

    }

    function validCardAll(isCollect = true, isScrollTop = true) {
      let allValid = true;

      if (!validCardno(isCollect, isScrollTop)) {
        allValid = false;
      }

      if (!validCardDate(isCollect, isScrollTop)) {
        allValid = false;
      }

      if (!validCardCVV(isCollect, isScrollTop)) {
        allValid = false;
      }

      return allValid
    }
    return { validCardno, validCardDate, validCardCVV, validCardAll }
  }

  function secondCardBindSubmit(callback, errorCallback) {
    document.getElementById("form_post").addEventListener("submit", function (event) {
      if (secondCardValids().validCardAll() && (callback ? callback() : true)) {
        return true
      } else {
        event.preventDefault();
        event.stopPropagation();
        errorCallback && errorCallback()
        return false
      }
    }, { capture: true });
  }

  function secondCardBindBlur(paymentMethodsConfig) {
    oemCreditCard({ rule: getCardConfig(paymentMethodsConfig) })
    document.getElementById("cardno_cover").addEventListener("keyup", function (event) {
      event.preventDefault(); event.stopPropagation();
    }, { capture: true });
    var acceptTxts = document.querySelectorAll(".accept_txt");
    for (const acceptTxt of acceptTxts) {
      acceptTxt.addEventListener("input", function (event) {
        $(this).parent().removeClass("valid-err");
        $(this).parent().find(".err").html("");
      }, { capture: true });
    }
    $("#cardno_cover").on("input", function (e) {
      var v = $(this).val();
      var cv = v.replace(/[^0-9 ]/g, '');
      $(this).val(cv);
      $("input[name='cardno']").val(v.replace(/[^0-9]/g, ""));
      $(".cardno_con").find(".err-svg").hide();
      const cardTypes = oemCreditCard.creditCardType(v.replace(/[^0-9]/g, ""), true)
      if (cardTypes.length && cardTypes.length === 1) {
        $(".cardno_con").find(".default-svg").hide();
        $("input[name='card_type']").val(cardTypes[0].name);
        $(".cardno_con img").attr("src", `https://dkrunsole.com/${cardTypes[0].imgUrl}`).show();
      } else {
        $(".cardno_con").find(".default-svg").show();
        $(".cardno_con").find("img").hide();
      }
    })
    $("#cardno_cover").on("blur", function () {
      var v = $(this).val().replace(/\s/g, "");
      if (!secondCardValids().validCardno(false, false)) {
      } else {
        $(this).parent().removeClass("valid-err");
        $(this).parent().find(".err").html("");
      }
    });

    $("input[name='date']").on("blur", secondCardValids().validCardDate.bind(null, false, false))
    $("input[name='cvv']").on("blur", secondCardValids().validCardCVV.bind(null, false, false))
    $("input[name='cvv']").on("input", function () {
      var value = $(this).val();
      $(this).val(value.replace(/[^\d]/g, ''));
    })

  }
</script>
<script type="text/javascript">

  var language = new Array();
  var button_click = false;
  var brandId = 19;
  var brandIds = JSON.parse(JSON.stringify([120, 191, 192]));



  language = { "cn": { "credit_card": "\u4fe1\u7528\u5361", "button": "\u652f\u4ed8", "cardno": "\u5361\u53f7", "cvv_empty": "\u5b89\u5168\u7801\u4e0d\u80fd\u4e3a\u7a7a", "year_empty": "\u8bf7\u9009\u62e9\u6709\u6548\u671f(\u5e74)", "month_empty": "\u8bf7\u9009\u62e9\u6709\u6548\u671f(\u6708)", "cardno_error": "\u5361\u53f7\u4e0d\u6b63\u786e", "cvv_error": "\u5b89\u5168\u7801\u4f4d\u6570\u4e3a3\u4f4d\u6216\u80054\u4f4d" }, "tc": { "credit_card": "\u4fe1\u7528\u5361", "button": "\u652f\u4ed8", "cardno": "\u5361\u865f", "cvv_empty": "\u5b89\u5168\u78bc\u4e0d\u80fd\u70ba\u7a7a", "year_empty": "\u8acb\u9078\u64c7\u6709\u6548\u671f(\u5e74)", "month_empty": "\u8acb\u9078\u64c7\u6709\u6548\u671f(\u6708)", "cardno_error": "\u5361\u865f\u4e0d\u6b63\u78ba", "cvv_error": "\u5b89\u5168\u78bc\u4f4d\u6578\u70ba3\u4f4d\u6216\u80054\u4f4d" }, "en": { "credit_card": "Credit Card", "button": "Pay", "cardno": "Card Number", "cvv_empty": "The CVV is error", "year_empty": "The Expiration Year is erro", "month_empty": "he Expiration Month is error", "cardno_error": "The Card Number is error", "cvv_error": "The CVV is error" }, "fr": { "credit_card": "Carte de cr\u00e9dit", "button": "Payer", "cardno": "Num\u00e9ro de carte", "cvv_empty": "Le CVV est faux", "year_empty": "L'ann\u00e9e d'expiration est fause", "month_empty": "Le mois d'expiration est faux", "cardno_error": "Le num\u00e9ro de carte\u00a0est faux", "cvv_error": "Le\u00a0CVV\u00a0est faux" }, "jp": { "credit_card": "\u30af\u30ec\u30b8\u30c3\u30c8\u30ab\u30fc\u30c9", "button": "\u652f\u6255\u3046", "cardno": "\u30ab\u30fc\u30c9\u756a\u53f7", "cvv_empty": "\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b3\u30fc\u30c9\u306f\u7a7a\u767d\u306b\u306a\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093", "year_empty": "\u6709\u52b9\u671f\u9593\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\uff08\u5e74\uff09", "month_empty": "\u6709\u52b9\u671f\u9593\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\uff08\u6708\uff09", "cardno_error": "\u30ab\u30fc\u30c9\u756a\u53f7\u306f\u6b63\u3057\u304f\u306a\u3044", "cvv_error": "\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b3\u30fc\u30c9\u306e\u6570\u306f3\u4f4d\u307e\u305f\u306f4\u4f4d\u3067\u3042\u308b" }, "ru": { "credit_card": "\u0411\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0430", "button": "\u041e\u043f\u043b\u0430\u0442\u0438\u0442\u044c", "cardno": "\u041d\u043e\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u044b", "cvv_empty": "CVV \u043a\u043e\u0434", "year_empty": "\u0414\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430 \u043a\u0430\u0440\u0442\u0430", "month_empty": "\u0414\u043e \u043a\u0430\u043a\u043e\u0433\u043e \u043c\u0435\u0441\u044f\u0446\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430 \u043a\u0430\u0440\u0442\u0430", "cardno_error": "\u041d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u044b", "cvv_error": "CVV \u043a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3 \u0438\u043b\u0438 4 \u0437\u043d\u0430\u043a\u043e\u0432" }, "it": { "credit_card": "Carta di credito", "button": "Pagamento", "cardno": "Numero di carta", "cvv_empty": "Il codice di sicurezza non pu\u00f2 essere vuoto", "year_empty": "Per favore scegli la validit\u00e0(anno)", "month_empty": "Per favore scegli la validit\u00e0(mese)", "cardno_error": "Il numero di carta non \u00e8 corretto", "cvv_error": "Il codice di sicurezza deve essere 3 o 4" }, "cs": { "credit_card": "Kreditn\u00ed karta", "button": "Platit", "cardno": "\u010c\u00edslo karty" }, "da": { "credit_card": "Kreditkort", "button": "Betale", "cardno": "Kortnummer" }, "de": { "credit_card": "Kreditkarte", "button": "Zahlen", "cardno": "Kartennummer" }, "es": { "credit_card": "Tarjeta de cr\u00e9dito", "button": "Paga", "cardno": "N\u00famero de tarjeta" }, "fi": { "credit_card": "Luottokortti", "button": "Maksaa", "cardno": "Kortin numero" }, "gr": { "credit_card": "\u03a0\u03b9\u03c3\u03c4\u03c9\u03c4\u03b9\u03ba\u03ae \u03ba\u03ac\u03c1\u03c4\u03b1", "button": "\u03a0\u03bb\u03b7\u03c1\u03c9\u03bc\u03ae", "cardno": "\u0391\u03c1\u03b9\u03b8\u03bc\u03cc\u03c2 \u03ba\u03ac\u03c1\u03c4\u03b1\u03c2" }, "hu": { "credit_card": "Hitelk\u00e1rtya", "button": "Fizet\u00e9s", "cardno": "K\u00e1rtyasz\u00e1m" }, "id": { "credit_card": "Kartu kredit", "button": "Membayar", "cardno": "Nomor kartu" }, "kr": { "credit_card": "\uc2e0\uc6a9 \uce74\ub4dc", "button": "\uc9c0\ubd88", "cardno": "\uce74\ub4dc \ubc88\ud638" }, "nl": { "credit_card": "Kredietkaart", "button": "Betalen", "cardno": "Kaartnummer" }, "no": { "credit_card": "Kredittkort", "button": "Betale", "cardno": "Kortnummer" }, "pl": { "credit_card": "Karta kredytowa", "button": "Zap\u0142aci\u0107", "cardno": "Numer karty" }, "pt": { "credit_card": "Cart\u00e3o de cr\u00e9dito", "button": "Pagar", "cardno": "N\u00famero do cart\u00e3o" }, "ro": { "credit_card": "Card de credit", "button": "A plati", "cardno": "Num\u0103r de card" }, "sv": { "credit_card": "Kreditkort", "button": "Betala", "cardno": "Kortnummer" }, "th": { "credit_card": "\u0e1a\u0e31\u0e15\u0e23\u0e40\u0e04\u0e23\u0e14\u0e34\u0e15", "button": "\u0e08\u0e48\u0e32\u0e22\u0e40\u0e07\u0e34\u0e19", "cardno": "\u0e2b\u0e21\u0e32\u0e22\u0e40\u0e25\u0e02\u0e1a\u0e31\u0e15\u0e23" }, "tr": { "credit_card": "Kredi kart\u0131", "button": "\u00f6deme", "cardno": "Kart numaras\u0131" }, "vi": { "credit_card": "Th\u1ebb t\u00edn d\u1ee5ng", "button": "Tr\u1ea3", "cardno": "S\u1ed1 th\u1ebb" } };

  function checkDate(e) {
    var date = new Date().getFullYear()
    var type = e.inputType
    var ret = e.target.value
    var dateSplit = date.toString().split('')
    var dates = dateSplit.slice(2, dateSplit.length)

    if (/^0+$/.test(ret)) {
      ret = '0'
    }

    if (ret) {
      if (ret[0] === '/') ret = ''
      if (ret.length === 2 && isNaN(ret[1])) ret = ret.substring(0, 1)
      if (ret.length === 3 && isNaN(ret[2])) ret = ret.substring(0, 2)
    }

    var delCode = ['deleteContentBackward', 'deleteContentForward']
    var keyCode = ['insertFromPaste'].concat(delCode)

    if ((keyCode.includes(type) || !type) && ret) {
      var str = ret.split(/[^\d]/g)
      var strJoin = str.join('')
      if (strJoin.length === 1) {
        if (delCode.includes(type)) ret = strJoin
        else ret = '0' + strJoin + ' / '
      }
      if (strJoin.length === 2) {
        var start = strJoin.substring(0, 2)
        if (delCode.includes(type)) {
          var startStr = Number(start) > 12 ? '12' : start === '00' ? '01' : start
          ret = startStr
        } else ret = start > 12 ? 12 + ' / ' : start + ' / '
      }
      if (strJoin.length === 3) {
        var start = strJoin.substring(0, 2) > 12 ? 12 : strJoin.substring(0, 2)
        var end = strJoin.substring(2, 3) > dates[0] ? strJoin.substring(2, 3) : dates[0]
        ret = start + ' / ' + end
      }
      if (strJoin.length > 3) {
        var start = strJoin.substring(0, 2) > 12 ? 12 : strJoin.substring(0, 2)
        var end =
          strJoin.substring(2, 4) > dates.join('') ? strJoin.substring(2, 4) : dates.join('')
        ret = start + ' / ' + end
      }
    }

    if (!/[\d]+$/.test(ret)) {
      if (ret.split('/').length === 2 && !ret.includes(' ')) {
        ret = ret.substring(0, 2) + ' / '
      }
      if (ret.length > 5) {
        var text = ret.substring(5, ret.length)
        for (let i = 0; i < text.length; i++) {
          if (!/[\d]+$/.test(text[i])) {
            ret = ret.substring(0, 5 + i)
          }
        }
      }
      if (ret.includes('/')) {
        if (ret.length === 4) ret = ret.split(' /')[0]
        else ret = ret
      } else ret = ''
    }

    if (ret.includes('/')) {
      var splitRet = ret.split(' / ')
      if (splitRet[0].length > 2) {
        var newRetStart = Number(splitRet[0])
        if (splitRet[0] > 12) newRetStart = 12
        if (splitRet[0] < 10) newRetStart = '0' + splitRet[0]
        ret = newRetStart + ' / '
      } else {
        var val = splitRet[1]

        for (let index = 0; index < dates.length; index++) {
          if (val[index] > dates[index]) {
            ret = ret
            break
          }
          if (val[index] < dates[index]) ret = ret.substring(0, 4 + index + 1)
        }
      }
    }

    if (type === 'insertText') {
      if (!ret.includes('/')) {
        if (ret.length > 2) {
          var dateSplit = date.toString().split('')
          var dates = dateSplit.slice(2, dateSplit.length)
          var lastVal = ret.substring(2, 3)
          if (lastVal < dates[0]) {
            lastVal = dates[0]
          }
          ret = ret.substring(0, 2) + ' / ' + lastVal
        }

        if (ret.length === 2) {
          if (ret < 13) ret = ret + ' / '
          else ret = `12 / `
        }

        if (ret.length === 1 && ret > 1) ret = '0' + Number(ret) + ' / '
      }
    }

    if (ret.length > 7) ret = ret.substring(0, 7)

    e.target.value = ret
  }

  function checkEmpty(val) {
    if (val == '' || val == undefined || val == null) {
      button_click = false;
      return true;
    } else {
      return false;
    }
  }




  $(function () {
    $("#form_post").submit(function (e) {
      console.log(new Date().getTime())
      if (button_click) {
        return false;
      } else {
        button_click = true;
      }




      $('#submit').attr('disabled', true);
      return true;
    });

    $("#cardno_cover").on("input", function () {
      var v = $(this).val();
      let caret = this.selectionStart;
      var formatVal = v.replace(/\s/g, '').replace(/(.{4})/g, "$1 ");
      if (caret === v.length) {
        caret += 1
      }
      $(this).val($.trim(formatVal));
      this.selectionEnd = caret;
    })
    $('.accept_btn').attr('disabled', false)

    secondCardBindBlur({});
      secondCardBindSubmit(function () {
        return true;
      });
  })
</script>